<?php
/**
 *      [Elitechmedia!] (C)2001-2099 MYSELF Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: login.php 22609 2011-05-16 01:55:33Z zhangchaofeng
 */
if(!isset($_SESSION)){
	session_start();
}
include_once("classes/DB.class.php");
include_once("function/member.php");
include_once("function/util.func.php");
date_default_timezone_set('Asia/Shanghai');
$uname=$_POST['username'];
$upasd=$_POST['password'];
$username=addslashes($uname);
$userpasd=md5($upasd);
if($username && $userpasd)
{
	$uid = $GLOBALS["DB"]->single("SELECT uid FROM user WHERE username='".$username."' AND password='".$userpasd."'");
	//echo "SELECT uid FROM user WHERE username='".$username."' AND password='".$userpasd."'";exit;
	$data['uid']=$uid;
	if($uid):
		$userinfo = $GLOBALS["DB"]->result("SELECT uid,c_id,username FROM user where uid='$uid'");
		$userinfo=$userinfo[0];
		$_SESSION['c_id']=$userinfo['c_id'];
		$_SESSION['uid']=$userinfo['uid'];
		$_SESSION['username']=$userinfo['username'];
	else:
		$data['message']="<font color='red'>对不起您的账号密码错误.</font>";
	endif;
}
echo json_encode($data);
